package com.epam.Xml;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

import org.apache.log4j.Logger;

public class TouristVoucher {
	
	private static Logger log = Logger.getLogger(TouristVoucher.class);
	static TouristVouchers<TouristVoucher> w = new TouristVouchers<TouristVoucher>();

	public enum Type {
		Shopping, Recreation, Sanatorium
	}

	public enum Country {
		France, Turkey, China, Thailand, Czech
	}

	public int getId() {
		return id;
	}

	public static TouristVouchers<TouristVoucher> getW() {
		return w;
	}

	@XmlAttribute
	public void setId(int id) {
		this.id = id;
	}

	public enum Transport {
		Plane, Train, Ship
	}

	private int id;
	private int duration;
	private Type type;
	private Country country;
	private Transport transport;
	private Hotel hotel;
	private Double cost;

	public TouristVoucher() {
		w.setVoucher(this);
	}

	public TouristVoucher(int id, int duration, Type type, Country country,
			Transport transport, Hotel hotel, Double cost) {
		super();
		this.id = id;
		this.duration = duration;
		this.type = type;
		this.country = country;
		this.transport = transport;
		this.hotel = hotel;
		this.cost = cost;
		w.setVoucher(this);
	}

	public int getDuration() {
		return duration;
	}

	@XmlElement
	public void setDuration(int duration) {
		this.duration = duration;
	}

	public Type getType() {
		return type;
	}

	@XmlElement
	public void setType(Type type) {
		this.type = type;
	}

	public Country getCountry() {
		return country;
	}

	@XmlElement
	public void setCountry(Country country) {
		this.country = country;
	}

	public Transport getTransport() {
		return transport;
	}

	@XmlElement
	public void setTransport(Transport transport) {
		this.transport = transport;
	}

	public Hotel getHotel() {
		return hotel;
	}

	@XmlElement
	public void setHotel(Hotel hotel) {
		this.hotel = hotel;
	}

	public Double getCost() {
		return cost;
	}

	@XmlElement
	public void setCost(Double cost) {
		this.cost = cost;
	}
	
	public String toString() {
		log.info("Voucher id: " + this.getId());
		log.info("Destination country: " + this.getCountry());
		log.info("Duration: " + this.getDuration() + " days");
		log.info("Transport: " + this.getTransport());
		log.info("Voucher type: " + this.getType());
		log.info("Hotel name: " + this.getHotel().getName());
		log.info("Room capacity: " + this.getHotel().getCapacity());
		log.info("Feeding: " + this.getHotel().getFeeding());
		log.info("Hotel rating: " + this.getHotel().getStars() + " stars");
		log.info("Voucher cost " + this.getCost());
		return "";
	}

	public static TouristVouchers<TouristVoucher> voucherInit() {

		TouristVoucher family = new TouristVoucher();
		family.setId(1);
		family.setCountry(Country.Turkey);
		family.setDuration(10);
		family.setHotel(Hotel.getHotels().get(0));
		family.setTransport(Transport.Plane);
		family.setType(Type.Recreation);
		family.setCost(2500.0);

		TouristVoucher romantic = new TouristVoucher();
		romantic.setId(2);
		romantic.setCountry(Country.Czech);
		romantic.setDuration(14);
		romantic.setHotel(Hotel.getHotels().get(1));
		romantic.setTransport(Transport.Train);
		romantic.setType(Type.Sanatorium);
		romantic.setCost(3000.0);

		return w;
	}

}
